/*sigfork.c*/
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include<stdlib.h>
void intsig_handler(int signumber, siginfo_t* siginfo, void* empty) {
    printf("int_handler, mypid=%d\n", getpid());
}

int main() {
    int pid;
    char arg[] = "-l";
    struct sigaction act;
    act.sa_sigaction = intsig_handler;
    act.sa_flags = SA_SIGINFO;
    if (sigaction(SIGINT, &act, NULL) < 0) {
        printf("install sigalerror\n");
    }
    printf("The parent pid=%d\n", getpid());
    pid = fork();
    if (pid < 0) {
        perror("fork failed!\n");
        exit(0);
    }
    printf("The return fork=%d\n", pid);

    // if (pid == 0) execvp("ls", &arg);
    // else
    //     while (1);
    return 0;
}
